package org.example.per;

public class Person {
    private int age;

    public int getAge() {
        return age;
    }
    //一旦方法里手动抛出异常,要么try catch异常处理,要么将方法做异常声明
    public void setAge(int age) throws Exception {
        if (age < 100){
            this.age = age;
        }else {
            //通过throw抛出异常对象
            //throw new Exception("age");
            throw new AgeException("age");
        }
    }
}
